//
//  MBDBaseViewController.swift
//  MasterBoy
//
//  Created by kyson on 2023/4/9.
//

import Foundation
import UIKit
import NVActivityIndicatorView

class MBDBaseViewController : UIViewController {
    
    private var activityIndicatorView : NVActivityIndicatorView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        activityIndicatorView = NVActivityIndicatorView(frame: UIScreen.main.bounds, type: .ballScale, color: UIColor(colorHex: 0x4273d0), padding: 0)
        self.view.addSubview(activityIndicatorView!)
                
    }
    
    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)
        
        if #available(iOS 13.0, *) {
            if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
                updateColors()
            }
        } else {
            // Fallback on earlier versions
        }
        
    }

    func updateColors() {
        view.setDynamicBackgroundColor()
        // 子类可以重写此方法来更新特定的UI元素
    }
    
    func startIndicatorAnimating(){
        self.activityIndicatorView.startAnimating()

    }
    
    func stopIndicatorAnimationg(){
        self.activityIndicatorView.stopAnimating()

    }
}
